//  <!-- 轮播图实现 -->
window.onload=function(){
    document.getElementById("l-btn").onclick=f2;
    document.getElementById("r-btn").onclick=f1;

    points = document.getElementById('points').children;
    //为底部按钮循环挂载事件
    for(var i= 0; i< points.length; i++){
        points[i].index = i;
        points[i].onclick = function(){
            clearInterval(interval);
            change(this.index);
            interval = setInterval(f1,3000);
        }
    }


    document.getElementById("l-btn").onmouseenter=function(){
        // 清除轮播
        clearInterval(interval);
    }
    document.getElementById("l-btn").onmouseleave=function(){
        // 开始轮播
        interval = setInterval(f1,3000);
    }
    document.getElementById("r-btn").onmouseenter=function(){
        // 清除轮播
        clearInterval(interval);
    }
    document.getElementById("r-btn").onmouseleave=function(){
        // 开始轮播
        interval = setInterval(f1,3000);
    }

}
var images=[
    "/images/main/64A4365FD64265F6AC244B048E2_1599CA3A_13F92.jpg",
    "/images/main/428F27372BFAABB1818C903F54C_7187F729_19D3B.jpg",
    "/images/main/ACB9E839523BD4AE89B156634F0_32D49921_29D1C.jpg",
    "/images/main/B9C023481E81D9D36A75F8A8E35_ACA55A12_18F04.jpg",
    "/images/main/EBCCF52DB64EF04C60D45E6FA6D_859E08DD_157A6.jpg"
];
var points = 0;
var n = 0;
function f1(){
    n++;
    if(n>4){
        n=0;
    }
    change(n);
}
function f2(){
    n--;
    if(n<0){
        n=images.length-1;
    }
    change(n);
}
var interval = setInterval(f1,3000);

function change(index){
    document.getElementById("looppic").src=images[index];
    for(var i = 0; i < points.length ; i++){
        points[i].className = 'normal';
    }
    points[index].className = 'shover';
    n = index;
}
